package com.sam;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mysql.jdbc.Driver;

public class Member {
	String userid;
	String username;
	String nickname;
	String password;
	String email;
	String status;
	String vid;
	
	String errorMsg;
	public static Connection conn;
	private boolean isValid;
	private String useridmsg;
	private String usernamemsg;
	private String nicknamemsg;
	private String passwordmsg;
	private String emmailMsg;
	private String loginmsg;
	
	protected Member() {
	
	}

	protected Member(String userid, String username, String nickname,
			String password, String email, String status, String vid) {
		super();
		this.userid = userid;
		this.username = username;
		this.nickname = nickname;
		this.password = password;
		this.email = email;
		this.status = status;
		this.vid = vid;
	}

	protected Member(String userid, String username, String nickname,
			String password, String email) {
		super();
		this.userid = userid;
		this.username = username;
		this.nickname = nickname;
		this.password = password;
		this.email = email;
	}
	
	protected Member(String userid, String password) {
		super();
		this.userid = userid;
		this.password = password;
	}

	public boolean checkField() {
		isValid = true;
		
		if(userid.length() < 4 || userid.length() > 20){
			isValid = false;
			useridmsg = "使用者帳號長度不符合!!";
		}
		
		if(username.length() < 4 || username.length() > 20) {
			isValid = false;
			usernamemsg = "使用者名稱長度不符合!!";
		}
		
		if(nickname.length() < 4 || nickname.length() > 20) {
			isValid = false;
			nicknamemsg = "暱稱長度不符合!!";
		}
		
		if(password.length() < 4 || password.length() > 20) {
			isValid = false;
			passwordmsg = "密碼長度不符合!!";
		}
		
		if(email.indexOf("@") == -1) {
			isValid = false;
			emmailMsg = "電子郵件格式不符合!!";
		}
		
		return isValid;
	}
	
	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getVid() {
		return vid;
	}

	public void setVid(String vid) {
		this.vid = vid;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	
}
